package main 
 
import "fmt" 
 
func main() { 
    // 先定义一个数组 
    var myArray [10]int = [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 
 
    // 基于数组创建一个数组切片 
    var mySlice []int = myArray[:5] 
 
    fmt.Println("Elements of myArray: ") 
    for _, v := range myArray { 
        fmt.Print(v, " ") 
    } 
 
    fmt.Println("\nElements of mySlice: ") 
    for _, v := range mySlice { 
        fmt.Print(v, " ") 
    } 
    fmt.Println() 
    
    aSlice := make([]int, 5, 10)
    fmt.Println("len(aSlice):", len(aSlice))
    fmt.Println("cap(aSlice):", cap(aSlice))
    
    aSlice = append(aSlice, 1,2,3,4)
    aSlice = append(aSlice, mySlice...)
    
    slice1 := []int{1, 2, 3, 4, 5}   
    slice2 := []int{5, 4, 3}  
    fmt.Println("\nElements of slice1: ") 
    for _, v := range slice1 { 
        fmt.Print(v, " ") 
    } 
    fmt.Println("\nElements of slice2: ") 
    for _, v := range slice2 { 
        fmt.Print(v, " ") 
    } 
    copy(slice2, slice1) // 只会复制slice1的前3个元素到slice2中 
    fmt.Println("\nElements of slice2: ") 
    for _, v := range slice2 { 
        fmt.Print(v, " ") 
    }
    copy(slice1, slice2) // 只会复制slice2的3个元素到slice1的前3个位置
    
    fmt.Println("\nElements of slice1: ") 
    for _, v := range slice1 { 
        fmt.Print(v, " ") 
    } 
 
}